home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / WASTE 1.0a4 Distribution / WASTE Headers / Pascal Interfaces / WASTE.p < prev   
Text File  |  1994-03-28  |  8KB  |  261 lines

  1. unit WASTE;
  2.  
  3. { Pascal interface to the WASTE text engine: }
  4. { version 1.0a3 }
  5.  
  6. { Copyright © 1993-1994 Merzwaren }
  7. { All Rights Reserved }
  8.  
  9. interface
  10.     uses
  11.         LongCoords;
  12.  
  13.     const
  14.  
  15. { alignment styles }
  16.  
  17.         weFlushLeft = -2;                        { flush left }
  18.         weFlushRight = -1;                    { flush right }
  19.         weFlushDefault = 0;                    { flush according to system direction }
  20.         weCenter = 1;                            { centered }
  21.         weJustify = 2;                            { fully justified }
  22.  
  23. { values for the mode parameter in WESetStyle and WEContinuousStyle }
  24.  
  25.         weDoFont = $0001;                    { set font family number }
  26.         weDoFace = $0002;                    { turn on the styles specified in tsFace }
  27.         weDoSize = $0004;                    { set type size }
  28.         weDoColor = $0008;                    { set color }
  29.         weDoAll = weDoFont + weDoFace + weDoSize + weDoColor;
  30.         weDoAddSize = $0010;                { adjust type size }
  31.         weDoToggleFace = $0020;            { turn a style off if it's continuous over the selection }
  32.         weDoReplaceFace = $0040;        { replace existing styles outright }
  33.  
  34. { values for the edge parameter in WEGetOffset etc. }
  35.  
  36.         kLeadingEdge = -1;                    { offset refers to leading edge of specified character }
  37.         kTrailingEdge = 0;                        { offset refers to trailing edge of previous character }
  38.  
  39. { values for WEFeatureFlag feature parameter }
  40.  
  41.         weFAutoScroll = 0;                    { automatically scroll the selection range into view }
  42.         weFOutlineHilite = 2;                { frame selection when deactivated }
  43.         weFInhibitRecal = 9;                    { don't recalculate line starts and don't redraw text }
  44.         weFUseTempMem = 10;            { use temporary memory for main data structures }
  45.         weFDrawOffscreen = 11;            { draw text offscreen for smoother visual results }
  46.  
  47. { values for WENew flags parameter }
  48.  
  49.         weDoAutoScroll = $0001;
  50.         weDoOutlineHilite = $0004;
  51.         weDoInhibitRecal = $0200;
  52.         weDoUseTempMem = $0400;
  53.         weDoDrawOffscreen = $0800;
  54.  
  55. { values for WEFeatureFlag action parameter }
  56.  
  57.         weBitClear = 0;                            { disables the specified feature }
  58.         weBitSet = 1;                            { enables the specified feature }
  59.         weBitTest = -1;                            { returns the current setting of the specified feature }
  60.  
  61. { values for WEGetInfo and WESetInfo selector parameter }
  62.  
  63.         weClickLoop = 'clik';                    { click loop callback }
  64.         wePort = 'port';                            { graphics port }
  65.         weRefCon = 'refc';                        { reference constant for use by application }
  66.         weScrollProc = 'scrl';                    { scroll callback }
  67.         weText = 'text';                            { handle to the raw text }
  68.         weTSMDocumentID = 'tsmd';        { Text Services Manager document ID }
  69.         weTSMPreUpdate = 'pre ';            { Text Services Manager pre-update callback }
  70.         weTSMPostUpdate = 'post';        { Text Services Manager post-update callback }
  71.  
  72.     type
  73.  
  74. { WASTE data types }
  75.  
  76.         WERunInfo = record
  77.                 runStart: LongInt;            { byte offset to first character of style run }
  78.                 runEnd: LongInt;            { byte offset past last character of style run }
  79.                 runHeight: Integer;        { line height (ascent + descent + leading) }
  80.                 runAscent: Integer;        { font ascent }
  81.                 runStyle: TextStyle;        { text attributes }
  82.             end;  { WERunInfo }
  83.  
  84.         WEHandle = Handle;
  85.  
  86. { callback prototypes }
  87.  
  88. { FUNCTION MyClickLoop(hWE: WEHandle): Boolean; }
  89.         WEClickLoopProcPtr = ProcPtr;
  90.  
  91. { PROCEDURE MyScrollProc(hWE: WEHandle); }
  92.         WEScrollProcPtr = ProcPtr;
  93.  
  94. { PROCEDURE MyTSMPreUpdate(hWE: WEHandle); }
  95.         WETSMPreUpdateProcPtr = ProcPtr;
  96.  
  97. { FUNCTION MyTSMPostUpdate(hWE: WEHandle; fixLength: LongInt; }
  98. {         inputAreaStart, inputAreaEnd:LongInt; }
  99. {        pinRangeStart, pinRangeEnd: LongInt); }
  100.         WETSMPostUpdateProcPtr = ProcPtr;
  101.  
  102. { WASTE Public Calls }
  103.  
  104. { creation and destruction }
  105.     function WENew (destRect, viewRect: LongRect;
  106.                                     flags: Integer;
  107.                                     var hWE: WEHandle): OSErr;
  108.     procedure WEDispose (hWE: WEHandle);
  109.  
  110. { getting variables }
  111.     function WEGetText (hWE: WEHandle): Handle;
  112.     function WEGetChar (offset: LongInt;
  113.                                     hWE: WEHandle): Char;
  114.     function WEGetTextLength (hWE: WEHandle): LongInt;
  115.     function WECountLines (hWE: WEHandle): LongInt;
  116.     function WEGetHeight (startLine, endLine: LongInt;
  117.                                     hWE: WEHandle): LongInt;
  118.     procedure WEGetSelection (var selStart, selEnd: LongInt;
  119.                                     hWE: WEHandle);
  120.     procedure WEGetDestRect (var destRect: LongRect;
  121.                                     hWE: WEHandle);
  122.     procedure WEGetViewRect (var viewRect: LongRect;
  123.                                     hWE: WEHandle);
  124.     function WEIsActive (hWE: WEHandle): Boolean;
  125.  
  126. { setting variables }
  127.     procedure WESetSelection (selStart, selEnd: LongInt;
  128.                                     hWE: WEHandle);
  129.     procedure WESetDestRect (destRect: LongRect;
  130.                                     hWE: WEHandle);
  131.     procedure WESetViewRect (viewRect: LongRect;
  132.                                     hWE: WEHandle);
  133.  
  134. { accessing style run information }
  135.     function WEContinuousStyle (var mode: Integer;
  136.                                     var ts: TextStyle;
  137.                                     hWE: WEHandle): Boolean;
  138.     procedure WEGetRunInfo (offset: LongInt;
  139.                                     var info: WERunInfo;
  140.                                     we: Handle);
  141.  
  142. { converting byte offsets to screen positions and vice versa }
  143.     function WEGetOffset (thePoint: LongPoint;
  144.                                     var edge: SignedByte;
  145.                                     we: Handle): LongInt;
  146.     procedure WEGetPoint (offset: LongInt;
  147.                                     var thePoint: LongPoint;
  148.                                     var lineHeight: Integer;
  149.                                     we: Handle);
  150.  
  151. { finding words and lines }
  152.     procedure WEFindWord (offset: LongInt;
  153.                                     edge: SignedByte;
  154.                                     var wordStart, wordEnd: LongInt;
  155.                                     hWE: WEHandle);
  156.     procedure WEFindLine (offset: LongInt;
  157.                                     edge: SignedByte;
  158.                                     var lineStart, lineEnd: LongInt;
  159.                                     hWE: WEHandle);
  160.  
  161. { making a copy of a text range }
  162.     function WECopyRange (rangeStart, rangeEnd: LongInt;
  163.                                     hText: Handle;
  164.                                     hStyles: StScrpHandle;
  165.                                     hWE: WEHandle): OSErr;
  166.  
  167. { getting and setting the alignment style }
  168.     function WEGetAlignment (hWE: WEHandle): SignedByte;
  169.     procedure WESetAlignment (alignment: SignedByte;
  170.                                     hWE: WEHandle);
  171.  
  172. { recalculating line breaks, drawing and scrolling }
  173.     function WECalText (hWE: WEHandle): OSErr;
  174.     procedure WEUpdate (updateRgn: RgnHandle;
  175.                                     hWE: WEHandle);
  176.     procedure WEScroll (hOffset, vOffset: LongInt;
  177.                                     hWE: WEHandle);
  178.     procedure WESelView (hWE: WEHandle);
  179.  
  180. { handling activate/deactivate events }
  181.     procedure WEActivate (hWE: WEHandle);
  182.     procedure WEDeactivate (hWE: WEHandle);
  183.  
  184. { handling key-down events }
  185.     procedure WEKey (key: Char;
  186.                                     modifiers: Integer;
  187.                                     hWE: WEHandle);
  188.  
  189. { handling mouse-down events and mouse tracking }
  190.     procedure WEClick (hitPt: Point;
  191.                                     modifiers: Integer;
  192.                                     clickTime: LongInt;
  193.                                     hWE: WEHandle);
  194.  
  195. { adjusting the cursor shape }
  196.     function WEAdjustCursor (mouseLoc: Point;
  197.                                     mouseRgn: RgnHandle;
  198.                                     hWE: WEHandle): Boolean;
  199.  
  200. { blinking the caret }
  201.     procedure WEIdle (var maxSleep: LongInt;
  202.                                     hWE: WEHandle);
  203.  
  204. { modifying the text and the styles }
  205.     function WEInsert (textPtr: Ptr;
  206.                                     textLength: LongInt;
  207.                                     styleScrap: STScrpHandle;
  208.                                     hWE: WEHandle): OSErr;
  209.     function WEDelete (hWE: WEHandle): OSErr;
  210.     function WESetStyle (mode: Integer;
  211.                                     ts: TextStyle;
  212.                                     hWE: WEHandle): OSErr;
  213.     function WEUseText (text: Handle;
  214.                                     hWE: WEHandle): OSErr;
  215.     function WEUseStyleScrap (styleScrap: STScrpHandle;
  216.                                     hWE: WEHandle): OSErr;
  217.  
  218. { Clipboard operations }
  219.     function WECut (hWE: WEHandle): OSErr;
  220.     function WECopy (hWE: WEHandle): OSErr;
  221.     function WEPaste (hWE: WEHandle): OSErr;
  222.  
  223. { Script Manager utilities }
  224.     function WECharByte (offset: LongInt;
  225.                                     hWE: WEHandle): Integer;
  226.     function WECharType (offset: LongInt;
  227.                                     hWE: WEHandle): Integer;
  228.  
  229. { Text Services Manager support }
  230.     function WEInstallTSMHandlers: OSErr;
  231.     procedure WEStopInlineSession (hWE: WEHandle);
  232.  
  233. { additional features }
  234.     function WEFeatureFlag (feature: Integer;
  235.                                     action: Integer;
  236.                                     hWE: WEHandle): Integer;
  237.     function WEGetInfo (selector: OSType;
  238.                                     info: univ Ptr;
  239.                                     hWE: WEHandle): OSErr;
  240.     function WESetInfo (selector: OSType;
  241.                                     info: univ Ptr;
  242.                                     hWE: WEHandle): OSErr;
  243.  
  244. { long coordinates utility routines }
  245.     procedure WELongPointToPoint (lp: LongPoint;
  246.                                     var p: Point);
  247.     procedure WEPointToLongPoint (p: Point;
  248.                                     var lp: LongPoint);
  249.     procedure WESetLongRect (var lr: LongRect;
  250.                                     left, top, right, bottom: LongInt);
  251.     procedure WELongRectToRect (lr: LongRect;
  252.                                     var r: Rect);
  253.     procedure WERectToLongRect (r: Rect;
  254.                                     var lr: LongRect);
  255.     procedure WEOffsetLongRect (var lr: LongRect;
  256.                                     hOffset, vOffset: LongInt);
  257.     function WELongPointInLongRect (lp: LongPoint;
  258.                                     lr: LongRect): Boolean;
  259.  
  260. implementation
  261. end.